type State = number

// actionType
export const enum ACTION_TYPE {
  "PLUS" = "PLUS",
  "MINUS" = "MINUS"
}

interface PlusAction {
  type: ACTION_TYPE.PLUS
  payload: number
}

interface MinusAction {
  type: ACTION_TYPE.MINUS
  payload: number
}

type Action = PlusAction | MinusAction

function counterTwoReducer(state: State, action: Action) {
  switch (action.type) {
    case ACTION_TYPE['PLUS']:
      return state + action.payload
    case ACTION_TYPE['MINUS']:
      return state - action.payload
    default:
      return state
  }
}

export default counterTwoReducer
